var editor;

function initEditor() {
    var E = window.wangEditor
    editor = new E('.editor')
        //debug调试
    editor.customConfig.debug = true
    editor.customConfig.zIndex = 9
        // 表情面板
    editor.customConfig.emotions = [{
            title: 'emoji',
            type: 'emoji',
            content: ['😀', '😃', '😄', '😁', '😆', '😉', '😋', '😗', '😮', '😤', '😡', '🤭', '😏', '😍', '😘', '😱', '😣', '❤️', '🖤', '💖', '💌', '☃️', '🙈', '👿', '🤧', '💜', '💕', '💛', '🧡', '💚', '💬', '🤡', '🧐', '🤢', '😽', '🙄']
        }]
        // 关闭粘贴内容中的样式
    editor.customConfig.pasteFilterStyle = false
        //跨域传递 cookie
        // editor.customConfig.withCredentials = true
    editor.customConfig.uploadFileName = 'file';

    editor.customConfig.uploadImgServer = `${httpurl}/uploadImgQiniu?pathName=productImg&&divisor=0&dividend=1`;   // 上传图片到服务器
    editor.customConfig.uploadImgHooks = {
        before: function(xhr, editor, files) {},
        success: function(xhr, editor, res) {
            console.log("上传成功");
            console.log(res);
        },
        fail: function(xhr, editor, result) {
            console.log("上传失败,原因是" + result);
        },
        error: function(xhr, editor) {
            console.log("上传出错");
        },
        timeout: function(xhr, editor) {
            console.log("上传超时");
        },
        customInsert: function(insertImg, res, editor) {
            console.log(res);
            if (res.rtnCode === 200) {
              var url = visitimgurl + res.msg;
              insertImg(url);
            }

            // result 必须是一个 JSON 格式字符串！！！否则报错
        }
    }

    editor.create()
}



